﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class User_Add : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        UserPower.CheckAction((int)FreeHouse.Power.Actions.TUser.Add);
    }
    protected void save_Click(object sender, EventArgs e)
    {
        FreeHouse.Model.TUser user = new FreeHouse.Model.TUser();
        user.UserName = UserName.Text;
        user.Password = password.Text;
        error.Text = "";
        if (user.UserName.Trim() == "")
            error.Text += "<p>填写用户名.</p>";
        if (user.Password.Trim() == "")
            error.Text += "<p>输入密码.</p>";
        //判断用户是否存在
        if (error.Text==""&&new FreeHouse.BLL.TUser().Exists(user.UserName))
            error.Text += "用户已存在.";
        if (error.Text != "") return;
       
        if (new FreeHouse.BLL.TUser().Add(user) > 0)
            error.Text = "添加成功.";
    }
}
